﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Kassasysteem_TacoTruijens
{
    public partial class paysubscription : System.Web.UI.Page
    {
        private DataClassesDataContext Database = new DataClassesDataContext();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        private BijzondereKaart createSubscription()
        {
            String firstname = Request.QueryString["firstname"];
            String lastname = Request.QueryString["lastname"];
            DateTime birthday = DateTime.Parse(Request.QueryString["birthday"]);
            DateTime endDate = DateTime.Parse(Request.QueryString["enddate"]);

            BijzondereKaart specialTicket = new BijzondereKaart();
            specialTicket.Type = "Abonnement";
            specialTicket.Voornaam = firstname;
            specialTicket.Achternaam = lastname;
            specialTicket.Geboortedatum = birthday;
            specialTicket.Verloopdatum = endDate;

            Database.BijzondereKaarts.InsertOnSubmit(specialTicket);
            Database.SubmitChanges();

            return specialTicket;
        }

        protected void buttonNext_Click(object sender, EventArgs e)
        {
            BijzondereKaart specialTicket = createSubscription();
            String queryString = "printsubscription.aspx?firstname=" + specialTicket.Voornaam + "&lastname=" + specialTicket.Achternaam + "&birthday=" + specialTicket.Geboortedatum.ToString() + "&enddate=" + specialTicket.Verloopdatum.ToString();
            Response.Redirect(queryString);
        }
    }
}